home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / mf-db.zip / VBSAMPLE\BCARDS.BAS < prev    next >
BASIC Source File  |  1993-10-02  |  3KB  |  103 lines

  1. Option Explicit
  2.  
  3. ' Index information for 'person' in db
  4. Type tperson
  5.     LNAME As String * 20
  6.     FNAME As String * 20
  7. End Type
  8. ' Index information for 'company name' in db
  9. Type tCompany
  10.     cName As String * 30
  11. End Type
  12. ' Index information for a reference in db (just to
  13. ' show integer access to the database...)  Note: we
  14. ' can 'concatenate' integers if we wanted to.  MF will
  15. ' not 'add' the value of 2 (or more) integers.  It
  16. ' will create 'sub-groups' within each integer.
  17. ' To demonstrate, remove the "'" from the second
  18. ' piece of data (ref2) and if you assign ref2 to
  19. ' different #'s, you will see that they are subgrouped
  20. ' in ref.
  21. Type tRef
  22.     ref As Integer
  23.     'ref2 As Integer
  24. End Type
  25. ' More 'actual' data for the DB
  26. Type tData
  27.     Street As String * 30
  28.     City As String * 20
  29.     State As String * 2
  30.     Zip As String * 9
  31.     Voice As String * 13
  32.     Fax As String * 13
  33. End Type
  34.  
  35. ' This is the ENTIRE record... it is made up of
  36. ' the 3 index types and the 'data' type
  37. Type tcard
  38.     person As tperson
  39.     company As tCompany
  40.     ref As tRef
  41.     data As tData
  42. End Type
  43.  
  44. Global person  As tperson
  45. Global card  As tcard
  46.  
  47. ' We have another database - REFERENCE -
  48. ' In this case, we don't want to bother having a
  49. ' whole bunch of type definitions -- we are just
  50. ' going to hard-code the structure.  This is a
  51. ' 'less' portable design (e.g. in the CARD example,
  52. ' above) if we modify  a field or WIDTH, it will
  53. ' automatically adjust the size of the database.
  54. ' this example will not automatically adjust.
  55. ' ---
  56. ' This database demonstrates 'grouping' withing
  57. ' integer fields.
  58. Type tReference
  59.     'Index 0
  60.     ref As Integer
  61.     refsub As Integer
  62.     ' Data
  63.     name As String * 25
  64.  
  65. End Type
  66.  
  67. ' Global reference to the reference database
  68. Global refDBHndl As Integer    ' Hndl to reference DB
  69.  
  70. Global PassL As Long
  71. Global Const ASMODAL = 1    ' Display a form modally
  72. Global Const PHOURGLASS = 11
  73. Global Const PNORMAL = 0
  74.  
  75. ' Nice variables to have around...when using VB...
  76. Global junk As Integer
  77. Global junki As Integer
  78. Global junkl As Long
  79.  
  80. ' semi-Generic LOAD COMBO BOX routine
  81. Sub load_refs (ctrl As Control)
  82.     Dim lCurRec As Long, ref As tReference
  83.  
  84.     ' remove old junk in the control
  85.     ctrl.Clear
  86.     ' load list with data
  87.     ' Get the first record in index order
  88.     lCurRec = mfTop(TaskHndl, refDBHndl, 0)
  89.     ' Loop until EOF, basically...
  90.     Do While lCurRec > 0
  91.         junk = mfRead(lCurRec, ref, TaskHndl, refDBHndl, MFRW_ALL)
  92.         If junk <> 0 Then
  93.             MsgBox "Error on read: " + Str$(junk)
  94.         End If
  95.         ctrl.AddItem Format$(ref.ref, "##") + " " + Format$(ref.refsub, "##") + " " + ref.name
  96.  
  97.         ' Get the next record in index order
  98.         lCurRec = mfSkip(lCurRec, 1, TaskHndl, refDBHndl, 0)
  99.     Loop
  100.  
  101. End Sub
  102.  
  103.